import ajax from '../../utils/ajax.js'

const form = document.forms[0];
// console.log("组织了" + form);


form.onsubmit = async function (e) {
    e.preventDefault();
    const result = await ajax('post', '/api/users/reg', {
        username: form.username.value,
        password: form.password.value,
        sex: form.sex.value,
        birthday: form.birthday.value,
        phone: form.phone.value,
        address: form.address.value,
    })
    if (result.flag) {
        alert('注册成功')
        localStorage.setItem('token', result.token)
        location.assign('index.html')
    }
}